import { Component, OnInit, ViewChild, Injector, AfterViewInit, ViewEncapsulation, ElementRef } from '@angular/core';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { SelectItem } from 'primeng/api';
import { AppComponentBase } from '@shared/common/app-component-base';
import { Table } from 'primeng/table';
import { Paginator, LazyLoadEvent } from 'primeng/primeng';
//import { ExcelModalComponent } from '@app/shared/common/excel-modal/excel-modal.component';
import * as moment from 'moment';
import { BsDatepickerViewMode } from 'ngx-bootstrap/datepicker/models';
import { BsDatepickerConfig, BsDaterangepickerConfig } from 'ngx-bootstrap';
import { finalize } from 'rxjs/operators';
import * as G2 from '@antv/g2';
import { PrimengTableHelper } from '@shared/helpers/PrimengTableHelper';
import { LineInstanceServiceProxy, TaskLineState, ComboboxItemDto, TemplateServiceProxy } from '@shared/service-proxies/service-proxies';

@Component({
  templateUrl: './request.component.html',
  styleUrls: ['./request.component.css'],
  encapsulation: ViewEncapsulation.None,
  animations: [appModuleAnimation()]

})
export class RequestComponent extends AppComponentBase  implements OnInit {
 

  @ViewChild('dataTable') dataTable: Table;
  @ViewChild('paginatorNormal') paginatorNormal: Paginator;
  @ViewChild('dataTableNormalProductions') dataTableNormalProductions: Table;

  advancedFiltersAreShown: Boolean = false;

  primengTableHelperNormalReport = new PrimengTableHelper();
  paginatorReport = new Paginator();  

  filterTaskModel: string = '';
  filterProductionDrawingCode: string = '';
  filterOnlyUntreated = false;

  constructor(
    injector: Injector,
    private _lineInstanceServiceProxy :LineInstanceServiceProxy,
    private _templateServiceProxy :TemplateServiceProxy,
  ) {
    super(injector);    
  }

  ngOnInit(): void {
   

  }
  


  getReport(event?: LazyLoadEvent) {
  

    this.primengTableHelperNormalReport.showLoadingIndicator();

    this._lineInstanceServiceProxy.getAllRequest(
      this.filterOnlyUntreated,
      this.filterTaskModel,
      this.filterProductionDrawingCode,
      this.primengTableHelperNormalReport.getSorting(this.dataTableNormalProductions),
      this.primengTableHelperNormalReport.getMaxResultCount(this.paginatorNormal, event),
      this.primengTableHelperNormalReport.getSkipCount(this.paginatorNormal, event)
    )
    .subscribe((result) => {
      this.primengTableHelperNormalReport.totalRecordsCount = result.totalCount;
      this.primengTableHelperNormalReport.records = result.items;
      this.primengTableHelperNormalReport.hideLoadingIndicator();
    });
  }

 

}